﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DosciWordPlugin.Common;

namespace DosciWordPlugin.Controls
{
    public partial class SetCitationStyle : Form
    {
        public string SelectedCitationStyle { get; set; }

        public SetCitationStyle()
        {
            InitializeComponent();
        }

        public void UpdateList() 
        {
            try
            {
                CacheManager.CitationStyleList.ForEach(style =>
                {
                    ListViewItem lvi = new ListViewItem();
                    lvi.ImageIndex = 0;
                    lvi.Text = style;
                    this.listView1.Items.Add(lvi);
                });
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
            }
        }

        private void btnApply_Click(object sender, EventArgs e)
        {
            try
            {
                if (listView1.SelectedItems == null || listView1.SelectedItems.Count <= 0)
                {
                    WinApp.MsgBoxInfo("请选择样式");
                    return;
                }

                SelectedCitationStyle = listView1.SelectedItems[0].Text;
                DialogResult = System.Windows.Forms.DialogResult.OK;
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex);
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            DialogResult = System.Windows.Forms.DialogResult.Cancel;
        }
    }
}
